﻿using System;
using Catel.Articles._02___WPF_controls.Data;
using Catel.Data;
using Catel.MVVM;

namespace Catel.Articles._02___WPF_controls.UI.ViewModels
{
    /// <summary>
    /// PersonSummary view model.
    /// </summary>
    public class PersonSummaryViewModel : ViewModelBase
    {
        #region Constructor & destructor
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonSummaryViewModel"/> class.
        /// </summary>
        /// <param name="person">The person.</param>
        public PersonSummaryViewModel(Person person)
            : base()
        {
            Person = person;
        }
        #endregion

        #region Properties
        /// <summary>
        /// Gets the title of the view model.
        /// </summary>
        /// <value>The title.</value>
        public override string Title { get { return "Person summary"; } }

        #region Models
        /// <summary>
        /// Gets or sets the person.
        /// </summary>
        [Model]
        public Person Person
        {
            get { return GetValue<Person>(PersonProperty); }
            private set { SetValue(PersonProperty, value); }
        }

        /// <summary>
        /// Register the Person property so it is known in the class.
        /// </summary>
        public static readonly PropertyData PersonProperty = RegisterProperty("Person", typeof(Person));
        #endregion

        #region View model
        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        [ViewModelToModel("Person")]
        public string FirstName
        {
            get { return GetValue<string>(FirstNameProperty); }
            set { SetValue(FirstNameProperty, value); }
        }

        /// <summary>
        /// Register the FirstName property so it is known in the class.
        /// </summary>
        public static readonly PropertyData FirstNameProperty = RegisterProperty("FirstName", typeof(string));

        /// <summary>
        /// Gets or sets the middle name.
        /// </summary>
        [ViewModelToModel("Person")]
        public string MiddleName
        {
            get { return GetValue<string>(MiddleNameProperty); }
            set { SetValue(MiddleNameProperty, value); }
        }

        /// <summary>
        /// Register the MiddleName property so it is known in the class.
        /// </summary>
        public static readonly PropertyData MiddleNameProperty = RegisterProperty("MiddleName", typeof(string));

        /// <summary>
        /// Gets or sets the last name.
        /// </summary>
        [ViewModelToModel("Person")]
        public string LastName
        {
            get { return GetValue<string>(LastNameProperty); }
            set { SetValue(LastNameProperty, value); }
        }

        /// <summary>
        /// Register the LastName property so it is known in the class.
        /// </summary>
        public static readonly PropertyData LastNameProperty = RegisterProperty("LastName", typeof(string));

        /// <summary>
        /// Gets or sets the birthday.
        /// </summary>
        [ViewModelToModel("Person")]
        public DateTime Birthday
        {
            get { return GetValue<DateTime>(BirthdayProperty); }
            set { SetValue(BirthdayProperty, value); }
        }

        /// <summary>
        /// Register the Birthday property so it is known in the class.
        /// </summary>
        public static readonly PropertyData BirthdayProperty = RegisterProperty("Birthday", typeof(DateTime));

        /// <summary>
        /// Gets or sets the passport photo.
        /// </summary>
        [ViewModelToModel("Person")]
        public string PassportPhoto
        {
            get { return GetValue<string>(PassportPhotoProperty); }
            set { SetValue(PassportPhotoProperty, value); }
        }

        /// <summary>
        /// Register the PassportPhoto property so it is known in the class.
        /// </summary>
        public static readonly PropertyData PassportPhotoProperty = RegisterProperty("PassportPhoto", typeof(string));
        #endregion
        #endregion

        #region Methods
        #endregion
    }
}
